home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / oleo-1_4.lha / oleo-1.4 / cell.h < prev    next >
C/C++ Source or Header  |  1993-02-14  |  5KB  |  170 lines

  1. #ifndef CELLH
  2. #define CELLH
  3. /*    Copyright (C) 1990, 1992, 1993 Free Software Foundation, Inc.
  4.  
  5. This file is part of Oleo, the GNU Spreadsheet.
  6.  
  7. Oleo is free software; you can redistribute it and/or modify
  8. it under the terms of the GNU General Public License as published by
  9. the Free Software Foundation; either version 2, or (at your option)
  10. any later version.
  11.  
  12. Oleo is distributed in the hope that it will be useful,
  13. but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15. GNU General Public License for more details.
  16.  
  17. You should have received a copy of the GNU General Public License
  18. along with Oleo; see the file COPYING.  If not, write to
  19. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  20.  
  21. /* Various structures and stuff for the spreadsheet */
  22.  
  23. /* A union of possible values for a location in the spreadsheet
  24.    (or a location to evaluate to:  This includes c_r, which
  25.    a VAR, etc may evaluate to, but which no cell can ever contain */
  26. #include "global.h"
  27. #include "font.h"
  28.  
  29. union vals
  30.   {
  31.     double c_d;
  32.     char *c_s;
  33.     long c_l;
  34.     int c_i;
  35.     struct rng c_r;
  36.   };
  37.  
  38. /* An actual cell structure.  These cannot be variable-length, since they are
  39.    allocated as a variable-length array on a col structure. */
  40.  
  41. struct cell
  42.   {
  43.     /* char *cell_string; */
  44.     short cell_flags;
  45.     struct font_memo * cell_font;
  46.     struct ref_fm *cell_refs_from;
  47.     struct ref_to *cell_refs_to;
  48.     unsigned char *cell_formula;
  49.     unsigned short cell_cycle;
  50.     union vals c_z;
  51.   };
  52.  
  53. struct var
  54.   {
  55.     struct var *var_next;
  56.  
  57.     short var_flags;
  58.     struct rng v_rng;
  59.  
  60.     /* This is a list of the cells that reference this variable.  If the 
  61.      * variable changes, all the cells in the vars new range must be given
  62.      * ref_froms that point to these variables
  63.      */
  64.     struct ref_fm *var_ref_fm;
  65.  
  66.     /* A variable sized array that holds the var-name. */
  67.     char var_name[1];
  68.   };
  69.  
  70. typedef struct cell CELL;
  71.  
  72. #define VAR_UNDEF 1
  73. #define VAR_CELL 2
  74. #define VAR_RANGE 3
  75. /* A var is only of this type between calls to start_shift_var and 
  76.  * finish_shift_var 
  77.  */
  78. #define VAR_DANGLING_RANGE 4
  79.  
  80. /* Shorthand for the cell union */
  81. #define cell_flt    c_z.c_d
  82. #define cell_str    c_z.c_s
  83. #define cell_int    c_z.c_l
  84. #define cell_bol    c_z.c_i
  85. #define cell_err    c_z.c_i
  86.  
  87. /* cell_flags is a 16bit value.  These bits have the following values
  88. 15   14   13   12 . 11   10    9    8  . 7    6    5    4  . 3    2    1    0 .
  89.  Unused | --Lock- | ----Type---- | Justify  | - Format --  | --- Precision ---
  90.  */
  91.  
  92. #define GET_LCK(p)    ((p)->cell_flags & 0x3000)
  93. #define SET_LCK(p,x)    (((p)->cell_flags &= ~0x3000),(p)->cell_flags |= x)
  94.  
  95. #define LCK_DEF        (0x0000)
  96. #define LCK_UNL        (0x1000)
  97. #define LCK_LCK        (0x2000)
  98.  
  99. /* The type of a cell, or of a eval_expression() value */
  100. #define GET_TYP(p)    ((p)->cell_flags & 0x0E00)
  101. #define SET_TYP(p,x)    ((p)->cell_flags &= ~0x0E00,(p)->cell_flags|=(x))
  102. #define TYP_FLT    0x0200
  103. #define TYP_INT    0x0400
  104. #define TYP_STR    0x0600
  105. #define TYP_BOL    0x0800
  106. #define TYP_ERR    0x0A00
  107. /* This for the expression evaluator:  NO cell should be this type */
  108. #define TYP_RNG 0x0E00
  109.  
  110. #define GET_JST(p)    ((p)->cell_flags & 0x0180)
  111. #define SET_JST(p,x)    ((p)->cell_flags &= ~0x0180,(p)->cell_flags|=(x))
  112. #define JST_DEF    0x0000
  113. #define JST_LFT 0x0100
  114. #define JST_RGT 0x0080
  115. #define JST_CNT 0x0180
  116.  
  117. #define GET_FMT(p)    ((p)->cell_flags & 0x007F)
  118. #define SET_FMT(p,x)    ((p)->cell_flags &= ~0x007F,(p)->cell_flags|=(x))
  119. #define GET_PRC(p)    ((p)&0x0F)
  120. #define PRC_FLT    0x0F
  121. #define FMT_DEF 0x0000
  122.  
  123. #define FMT_HID 0x000E
  124. #define FMT_GPH 0x000F
  125.  
  126. #define FMT_DOL 0x001F
  127. #define FMT_CMA 0x002F
  128. #define FMT_PCT 0x003F
  129. #define FMT_USR 0x004F
  130.  
  131. #define FMT_FXT 0x005F
  132. #define FMT_EXP 0x006F
  133. #define FMT_GEN 0x007F
  134.  
  135. #define FMT_MAX 0x007F
  136.  
  137. /* README README README
  138.  *
  139.  * The _make_ functions may cause the addresses of cells previously returned by
  140.  * find_ functions to change.  By extention, any function that calls a make_
  141.  * function can have that effect.  This is particularly nasty because pointers
  142.  * to cells are stored in the global my_cell, and in various stack frames.
  143.  * Several bugs have been traced to this questionable design -- please be
  144.  * careful not to add new ones.
  145.  */
  146.  
  147. #ifdef __STDC__
  148. extern CELL *find_cell (CELLREF, CELLREF);
  149. extern CELL *find_or_make_cell (CELLREF, CELLREF);
  150. extern void find_cells_in_range (struct rng *);
  151. extern void make_cells_in_range (struct rng *);
  152. extern CELL *next_cell_in_range (void);
  153. extern CELL *next_row_col_in_range (CELLREF *, CELLREF *);
  154. extern void no_more_cells (void);
  155. extern char *decomp (CELLREF, CELLREF, CELL *);
  156. extern void decomp_free (void);
  157. #else
  158. extern CELL *find_cell ();
  159. extern CELL *find_or_make_cell ();
  160. extern void find_cells_in_range ();
  161. extern void make_cells_in_range ();
  162. extern CELL *next_cell_in_range ();
  163. extern CELL *next_row_col_in_range ();
  164. extern void no_more_cells ();
  165. extern char *decomp ();
  166. extern void decomp_free ();
  167. #endif
  168.  
  169. #endif
  170.